package model

import (
	"github.com/cuiyuanxin/airuisi-admin/pkg/app"
	"gorm.io/gorm"
)

// 角色组表结构体
type Role struct {
	*Model
	Name   string `json:"name" xorm:"VARCHAR(50) notnull default('') comment('角色组名称')"`
	Code   string `json:"code" xorm:"VARCHAR(50) notnull default('') comment('角色唯一标识')"`
	Note   string `json:"note" xorm:"TEXT notnull comment('角色组备注')"`
	Status int    `json:"status" xorm:"TINYINT(2) notnull default('0') comment('角色组状态\n1:正常\n0:禁用\n-1:删除')"`
}

type RoleSwagger struct {
	List  []*Role
	Pager *app.Pager
}

func (r Role) Count(db *gorm.DB) (int, error) {
	//var count int
	//if t.Name != "" {
	//	db = db.Where("name = ?", t.Name)
	//}
	//db = db.Where("state = ?", t.State)
	//if err := db.Model(&t).Where("is_del = ?", 0).Count(&count).Error; err != nil {
	//	return 0, err
	//}
	//
	//return count, nil
	return 0, nil
}

func (r Role) List(db *gorm.DB, pageOffset, pageSize int) ([]*Role, error) {
	//var tags []*Tag
	//var err error
	//if pageOffset >= 0 && pageSize > 0 {
	//	db = db.Offset(pageOffset).Limit(pageSize)
	//}
	//if t.Name != "" {
	//	db = db.Where("name = ?", t.Name)
	//}
	//db = db.Where("state = ?", t.State)
	//if err = db.Where("is_del = ?", 0).Find(&tags).Error; err != nil {
	//	return nil, err
	//}
	//
	//return tags, nil
	return nil, nil
}

func (r Role) Create(db *gorm.DB) error {
	//return db.Create(&t).Error
	return nil
}

func (r Role) Update(db *gorm.DB) error {
	//return db.Model(&Tag{}).Where("id = ? AND is_del = ?", t.ID, 0).Update(t).Error
	return nil
}

func (r Role) Delete(db *gorm.DB) error {
	//return db.Where("id = ? AND is_del = ?", t.Model.ID, 0).Delete(&t).Error
	return nil
}
